package com.xtaller.sdboot.utils.captcha.strategy;

import com.xtaller.sdboot.utils.captcha.bean.CaptchaBean;
import com.xtaller.sdboot.utils.captcha.strategy.calculate.CalculateTypeEnum;

import java.awt.*;

/**
 * @version V1.0
 * @author: Taller
 * @date: 2019-06-17
 * @Description: 算数生成器
 */
public class CalculateCaptchaStrategy implements ICaptchaStrategy {
    private Integer number = 2;

    @Override
    public CaptchaBean generateCode() {
        CalculateTypeEnum calculatorType = CalculateTypeEnum.getRandomType();
        return calculatorType.getCalculator().create(number);
    }

    @Override
    public Font getFont(int size) {
        return new Font("宋体", Font.BOLD, size);
    }


    @Override
    public void setNumber(int number) {
        if (number != 2) {
            // log.warn("unsupport set not 2 number");
            return;
        }
        this.number = number;
    }
}
